from django.http import JsonResponse
from yushiminiapp.settings import CODE_MESSAGE
import datetime

def resultResponse(code=200,err_Msg="",data=None,_list=False):
    if _list:
        returnData = dict()
        returnData['data'] = data
        returnData['code'] = code
        returnData['message'] = CODE_MESSAGE[str(code)]
        return JsonResponse(returnData)
    if not data:
        data = dict()
    data['code'] = code 
    data['message'] = CODE_MESSAGE[str(code)]
    if code == 700:
        data['message'] = err_Msg
    return JsonResponse(data)

def getYushiAccount():
    return "{0:%Y%m%d%H%M%S}".format(datetime.datetime.now())
